<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="/webjars/bootstrap/3.3.7/css/bootstrap.css">
  <script type="text/javascript" src="/webjars/jquery/3.4.1/jquery.js"></script>
  <script type="text/javascript" src="/webjars/bootstrap/3.3.7/js/bootstrap.js"></script>
  <script type="text/javascript" src="/webjars/vue/2.6.10/dist/vue.js"></script>
  <script src="/webjars/axios/0.19.0/dist/axios.js" type="text/javascript"></script>
</head>
<body>
  <div id="vuebox">
    <h1>申报项目列表</h1>
    <div class="row">
      <div class="col-md-6">
        <form class="form-inline" role="form" style="padding-left: 250px;">
          <div class="form-group" style="padding-left: 20px;">
            <label>申报状态:</label>
            <select class="form-control" v-model="status">
              <option value="0">全部</option>
              <option value="1">已申报</option>
              <option value="2">审核中</option>
              <option value="3">已审核</option>
            </select>
          </div>
          <div class="form-group"  style="padding-left: 20px;">
            <button type="button" class="btn btn-primary" @click="selepro(1)">查询</button>
          </div>
        </form>
      </div>
    </div>
    <table class="table table-striped">
      <thead>
      <tr>
        <th>项目编号</th>
        <th>项目名称</th>
        <th>申报开始时间</th>
        <th>申报结束时间</th>
        <th>申报状态</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      <tr v-for="item in proList.list">
        <td>{{item.id}}</td>
        <td>{{item.projectname}}</td>
        <td>{{item.statartdate}}</td>
        <td>{{item.enddate}}</td>
        <td>
          <span v-if="item.status==1">已申报</span>
          <span v-if="item.status==2">审核中</span>
          <span v-if="item.status==3">已审核</span>
        </td>
        <td>
          <button type="button" @click="shenhe(item.id)" class="btn btn-primary" v-if="item.status!=3">审核</button>
        </td>
      </tr>
      <tr>
        <p v-if="proList.list!=undefined && proList.list.length<=0">没有查到数据</p>
      </tr>
      </tbody>
    </table>

    <ul class="pagination">
      <li><a href="#" @click.stop="selepro(proList.prePages)">&laquo;</a></li>

      <li :class="{'active':i==proList.pageNum}" v-for="i in proList.pages"><a href="#" @click.stop="selepro(i)">{{i}}</a></li>
      <li><a href="#" @click.stop="selepro(proList.nextPage)">&raquo;</a></li>
    </ul>

    <!--模态框-->
    <div class="modal" id="mymodal">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button @click="hideModal" class="close" type="button">&times;</button>
            <div class="modal-title">申报项目信息</div>
          </div>
          <div class="modal-body">
            <form class="form-horizontal" role="form">
              <div class="form-group">
                <label for="title" class="col-sm-2 control-label">项目编号</label>
                <div class="col-sm-10">
                  <input v-model="newpro.id" readonly id="title" type="text" class="form-control" placeholder="请输入图书名称">
                </div>
              </div>
              <div class="form-group">
                <label for="summary" class="col-sm-2 control-label">项目名称</label>
                <div class="col-sm-10">
                  <input v-model="newpro.projectname" readonly id="summary" type="text" class="form-control" placeholder="请输入图书摘要"/>
                </div>
              </div>
              <div class="form-group">
                <label for="uploaduser" class="col-sm-2 control-label">申报开始日期</label>
                <div class="col-sm-10">
                  <input v-model="newpro.statartdate" readonly id="uploaduser" type="text" class="form-control" placeholder="请输入上传人">
                </div>
              </div>
              <div class="form-group">
                <label for="createdate" class="col-sm-2 control-label">申报结束日期</label>
                <div class="col-sm-10">
                  <input v-model="newpro.enddate" readonly id="createdate" type="text" class="form-control" placeholder="请输入上传时间">
                </div>
              </div>
              <div class="form-group">
                <label for="categoryId" class="col-sm-2 control-label">申报状态</label>
                <div class="col-sm-10">
                  <select id="categoryId" class="form-control" v-model="newpro.status">
                    <option v-if="newpro.status==1" value="1">已申报</option>
                    <option value="2">审核中</option>
                    <option value="3">已审核</option>
                  </select>
                </div>
              </div>
            </form>
          </div>
          <div class="modal-footer">
            <button class="btn btn-default" @click="hideModal()">关闭</button>
            <button class="btn btn-primary" @click="saveBook">保存</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>
<script type="text/javascript">
        var vm=new Vue({
            el:"#vuebox",
            data:{
            status:"0",
            proList:{},
            newpro:{
                id:"",projectname:"",statartdate:"",enddate:"",status:""
            },
                result:""
            },
            methods:{
                selepro:function (id) {
                    axios.get("/selePro",{params:{status:this.status,pageNum:id}}).then(res=>{
                        this.proList=res.data;
                    })
                },
                shenhe:function (id) {
                axios.get("/seleById",{params:{id:id}}).then(res=>{
                    this.newpro=res.data;
                })
                    $("#mymodal").modal('show');
                },
                hideModal:function () {
                    $("#mymodal").modal('hide');
                },
                saveBook:function () {
                    axios.post("/upPro",this.newpro).then(res=>{
                        this.result=res.data;
                        if(this.result=="SUCCESS"){
                            alert("审核成功!")
                            this.hideModal();
                            this.selepro(1);
                        }else{
                            alert("审核失败!")
                        }
                    })
                }
            },
            mounted(){
                this.selepro(1);
            }
    })
</script>